const vm = new Vue({
    el: '#app',
    data: {
        loginForm: {
            use: '',
            pwd: ''
        },
        rulesLogin: {
            use: [
                { required: true, message: '请输入账号', trigger: 'blur' },
            ],
            pwd: [
                { required: true, message: '请选择密码', trigger: 'change' }
            ]
        }
    },
    methods: {
        submitLoginForm(formName) {
            this.$refs[formName].validate((valid) => {
                if (valid) {
                    axios.defaults.withCredentials = true;
                    axios.post('http://192.168.137.117:8080/order/user/login.action', `userName=${this.loginForm.use}&password=${this.loginForm.pwd}`)
                        .then(function (response) {
                            console.log(response);
                            if (response.data.ok) {
                                location.href = 'index.html';
                            } else {
                                vm.$message.warning(response.data.err);
                            }
                        })
                        .catch(function (error) {
                            vm.$message.error(error.response);
                        });
                } else {
                    console.log('没有提交成功');
                    return false;
                }
            });
        }
    }
});